package lvxu.service;

import lvxu.bean.Admin;
import lvxu.bean.AdminExample;
import lvxu.bean.User;
import lvxu.bean.UserExample;
import lvxu.dao.AdminMapper;
import lvxu.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminService {
    @Autowired
    AdminMapper adminMapper;


    public boolean login(Admin admin) {
        AdminExample adminExample = new AdminExample();
        AdminExample.Criteria criteria = adminExample.createCriteria();
        criteria.andAdminnameEqualTo(admin.getAdminname());
        criteria.andAdminpasswordEqualTo(admin.getAdminpassword());
        long index =  adminMapper.countByExample(adminExample);
        if (index != 0){
            return true;
        }else {
            return false;
        }
    }


    public List<Admin> selectAdimin(String adminname) {
        AdminExample adminExample = new AdminExample();
        AdminExample.Criteria criteria = adminExample.createCriteria();
        criteria.andAdminnameEqualTo(adminname);
        List<Admin> admins = adminMapper.selectByExample(adminExample);
        return admins;
    }
}
